package com.joysw.ui;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import butterknife.ButterKnife;
import butterknife.InjectView;

import com.joysw.R;
import com.joysw.utils.ConstantUtil;
import com.joysw.view.TitleBarView;

/**
 * 
* @Title: MainActivity.java 
* @Package com.joysw.ui 
* @Description: 个人信息页面
* @author LIMINGYAN  
* @date 2015年3月28日 上午7:39:14 
* @version V1.0
 */
public class MyselfInfoActivity extends BaseActivity implements OnClickListener{
	private static final String TAG = "MyIncomeActivity";
	@InjectView(R.id.myself_info_title_bar)
	TitleBarView title_bar_view;
	
	@InjectView(R.id.username)
	RelativeLayout username_info;
	@InjectView(R.id.qq_number)
	RelativeLayout qq_info;
	@InjectView(R.id.reset_password)
	RelativeLayout password_info;
	@InjectView(R.id.version_manager)
	RelativeLayout version_info;
	@InjectView(R.id.clear_cache)
	RelativeLayout cache_info;
	
	//要改变的textview
	@InjectView(R.id.account_name)
	TextView account_name;
	@InjectView(R.id.account_QQ)
	TextView account_QQ;
	@InjectView(R.id.my_phone_number)
	TextView account_phone_number;
	
	 @Override
	    protected void onCreate(Bundle arg0) {
	    	// TODO Auto-generated method stub
	    	super.onCreate(arg0);
	    	setContentView(R.layout.activity_myself_info);
	    	ButterKnife.inject(this);
	    	
	    	initView();
	    }
	private void initView() {
		
		username_info.setOnClickListener(this);
		qq_info.setOnClickListener(this);
		password_info.setOnClickListener(this);
		version_info.setOnClickListener(this);
		cache_info.setOnClickListener(this);
		
		title_bar_view.setTitleText(R.string.my_info_title);
		title_bar_view.setBtnLeft(R.drawable.ic_back, R.string.back);
		title_bar_view.setBtnLeftOnclickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				finish();
			}
		});
		
	}
	@Override
	public void onClick(View arg0) {
		Intent intent=new Intent(MyselfInfoActivity.this, ModifyAccountNameActivity.class);
		
		switch (arg0.getId()) {
		case R.id.username:
			intent.putExtra("data", account_name.getText().toString());
			intent.putExtra("type", "name");
			startActivityForResult(intent, ConstantUtil.NAME);
			break;
		case R.id.qq_number:
			intent.putExtra("data", account_QQ.getText().toString());
			intent.putExtra("type", "qq");
			startActivityForResult(intent, ConstantUtil.QQ);
			break;
		case R.id.reset_password:
			startActivity(new Intent(MyselfInfoActivity.this, ModifyPwdActivity.class));
			break;
		case R.id.version_manager:
			Toast.makeText(MyselfInfoActivity.this, "已经是最新版本", Toast.LENGTH_LONG).show();
			break;
		case R.id.clear_cache:
			Toast.makeText(MyselfInfoActivity.this, "缓存已经清除", Toast.LENGTH_LONG).show();
			break;
		default:
			break;
		}
		
	}
	 @Override  
	    protected void onActivityResult(int requestCode, int resultCode, Intent data)  
	    {  
	        //可以根据多个请求代码来作相应的操作  
	        if(ConstantUtil.NAME==resultCode)  
	        {  
	            String reset_name=data.getExtras().getString("reset_name");  
	            account_name.setText(reset_name);
	        } 
	        if(ConstantUtil.QQ==resultCode)  
	        {  
	            String reset_name=data.getExtras().getString("reset_name");  
	            account_QQ.setText(reset_name);
	        } 
	        super.onActivityResult(requestCode, resultCode, data);  
	    }  
	
}
